/**
 * Copyright (c) 2011, Todd Ginsberg
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *    * Neither the name of Todd Ginsberg, or Gowalla nor the
 *      names of any contributors may be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 *  Also, please use this for Good and not Evil.  
 */
package com.ginsberg.gowalla.dto;

import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Todd Ginsberg
 */
public class ReceiptComponent implements Serializable {

	private static final long serialVersionUID = -3978695875339654483L;
	private ReceiptComponentType type;
	private String message;
	private String image_url;
	private List<String> headings = null;
	private List<Button> buttons = null;
	
	// Not always included.
	private HighlightType highlightType;
	private Item item;
	private Pin pin;
	private List<User> users = null;
	private int duration_in_days;
	private User creator;
	
	/**
	 * Constructor!
	 */
	public ReceiptComponent() {
		super();
	}

	/**
	 * @return the pin
	 */
	public Pin getPin() {
		return pin;
	}

	/**
	 * @param pin the pin to set
	 */
	public void setPin(Pin pin) {
		this.pin = pin;
	}

	/**
	 * @return the item
	 */
	public Item getItem() {
		return item;
	}

	/**
	 * @param item the item to set
	 */
	public void setItem(Item item) {
		this.item = item;
	}

	/**
	 * @return the highlightType
	 */
	public HighlightType getHighlightType() {
		return highlightType;
	}

	/**
	 * @param highlightType the highlightType to set
	 */
	public void setHighlightType(HighlightType highlightType) {
		this.highlightType = highlightType;
	}

	/**
	 * @return the type
	 */
	public ReceiptComponentType getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(ReceiptComponentType type) {
		this.type = type;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * @return the image_url
	 */
	public String getImageUrl() {
		return image_url;
	}

	/**
	 * @param imageUrl the image_url to set
	 */
	public void setImageUrl(String imageUrl) {
		image_url = imageUrl;
	}

	/**
	 * @return the buttons
	 */
	public List<Button> getButtons() {
		return buttons == null ? Collections.EMPTY_LIST : buttons;
	}

	/**
	 * @param buttons the buttons to set
	 */
	public void setButtons(List<Button> buttons) {
		this.buttons = buttons;
	}
	
	public void addButton(Button button) {
		if(buttons == null) {
			buttons = new LinkedList<Button>();
		}
		buttons.add(button);
	}
	
	public void addHeading(String heading) {
		if(headings == null) {
			headings = new LinkedList<String>();
		}
		headings.add(heading);
	}

	/**
	 * @return the headings
	 */
	public List<String> getHeadings() {
		return headings == null ? Collections.EMPTY_LIST : headings;
	}

	/**
	 * @param headings the headings to set
	 */
	public void setHeadings(List<String> headings) {
		this.headings = headings;
	}

	/**
	 * @return the users
	 */
	public List<User> getUsers() {
		return users == null ? Collections.EMPTY_LIST : users;
	}
	
	public void addUser(User user) {
		if(users == null) {
			users = new LinkedList<User>();
		}
		users.add(user);
	}

	/**
	 * @param users the users to set
	 */
	public void setUsers(List<User> users) {
		this.users = users;
	}

	/**
	 * @return the duration_in_days
	 */
	public int getDurationInDays() {
		return duration_in_days;
	}

	/**
	 * @param durationInDays the duration_in_days to set
	 */
	public void setDurationInDays(int durationInDays) {
		duration_in_days = durationInDays;
	}

	/**
	 * @return the creator
	 */
	public User getCreator() {
		return creator;
	}

	/**
	 * @param creator the creator to set
	 */
	public void setCreator(User creator) {
		this.creator = creator;
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return String
				.format(
						"ReceiptComponent [type=%s, buttons=%s, duration_in_days=%s, headings=%s, highlightType=%s, image_url=%s, item=%s, message=%s, pin=%s, users=%s, creator=%s]",
						type, buttons, duration_in_days, headings, highlightType,
						image_url, item, message, pin, users, creator);
	}

}
